package com.legal.aid.system.service.impl;

import com.legal.aid.common.core.domain.model.LoginUser;
import com.legal.aid.common.utils.DateUtils;
import com.legal.aid.common.utils.SecurityUtils;
import com.legal.aid.system.domain.Lawyer;
import com.legal.aid.system.domain.vo.LawyerDetailVO;
import com.legal.aid.system.mapper.LawyerMapper;
import com.legal.aid.system.service.ILawyerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 律师信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-23
 */
@Service
public class LawyerServiceImpl implements ILawyerService 
{
    @Autowired
    private LawyerMapper lawyerMapper;

    /**
     * 查询律基本师信息
     * 
     * @param lawyerId 律师信息主键
     * @return 律师信息
     */
    @Override
    public LawyerDetailVO selectLawyerBaseInfoByLawyerId(Long lawyerId)
    {
        //返回律师信息信息
        return lawyerMapper.selectLawyerBaseInfoByLawyerId(lawyerId);
    }

    /**
     * 查询律师信息
     * @param lawyerId
     * @return
     */
    @Override
    public Lawyer selectLawyerByLawyerId(Long lawyerId) {


        return lawyerMapper.selectLawyerByLawyerId(lawyerId);
    }

    /**
     * 查询律师信息列表
     * 
     * @param lawyer 律师信息
     * @return 律师信息
     */
    @Override
    public List<Lawyer> selectLawyerList(Lawyer lawyer)
    {
        return lawyerMapper.selectLawyerList(lawyer);
    }

    /**
     * 新增律师信息
     * 
     * @param lawyer 律师信息
     * @return 结果
     */
    @Override
    public int insertLawyer(Lawyer lawyer)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        lawyer.setCreatedBy(loginUser.getUsername());
        lawyer.setCreateTime(DateUtils.getNowDate());
        return lawyerMapper.insertLawyer(lawyer);
    }

    /**
     * 修改律师信息
     * 
     * @param lawyer 律师信息
     * @return 结果
     */
    @Override
    public int updateLawyer(Lawyer lawyer)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        lawyer.setUpdatedBy(loginUser.getUsername());
        lawyer.setUpdateTime(DateUtils.getNowDate());
        return lawyerMapper.updateLawyer(lawyer);
    }

    /**
     * 批量删除律师信息
     * 
     * @param lawyerIds 需要删除的律师信息主键
     * @return 结果
     */
    @Override
    public int deleteLawyerByLawyerIds(Long[] lawyerIds)
    {
        return lawyerMapper.deleteLawyerByLawyerIds(lawyerIds);
    }

    /**
     * 删除律师信息信息
     * 
     * @param lawyerId 律师信息主键
     * @return 结果
     */
    @Override
    public int deleteLawyerByLawyerId(Long lawyerId)
    {
        return lawyerMapper.deleteLawyerByLawyerId(lawyerId);
    }


}
